<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Parses an address string</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="function.imap-reopen.html">« imap_reopen</a></li>
      <li style="float: right;"><a href="function.imap-rfc822-parse-headers.html">imap_rfc822_parse_headers »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="ref.imap.html">IMAP 函数</a></li>
    <li>Parses an address string</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="function.imap-rfc822-parse-adrlist" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">imap_rfc822_parse_adrlist</h1>
  <p class="verinfo">(PHP 4, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">imap_rfc822_parse_adrlist</span> &mdash; <span class="dc-title">Parses an address string</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-function.imap-rfc822-parse-adrlist-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>imap_rfc822_parse_adrlist</strong></span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$string</code></span>, <span class="methodparam"><span class="type">string</span> <code class="parameter">$default_hostname</code></span>): <span class="type">array</span></div>

  <p class="para rdfs-comment">
   Parses the address string as defined in <a href="http://www.faqs.org/rfcs/rfc2822" class="link external">&raquo;&nbsp;RFC2822</a> and for each address.
  </p>
 </div>

 <div class="refsect1 parameters" id="refsect1-function.imap-rfc822-parse-adrlist-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>
    
     <dt>
<code class="parameter">string</code></dt>

     <dd>

      <p class="para">
       A string containing addresses
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">default_hostname</code></dt>

     <dd>

      <p class="para">
       The default host name
      </p>
     </dd>

    
   </dl>

  </p>
 </div>

 <div class="refsect1 returnvalues" id="refsect1-function.imap-rfc822-parse-adrlist-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   Returns an array of objects. The objects properties are:
  </p>
  <p class="para">
   <ul class="itemizedlist">
    <li class="listitem">
     <span class="simpara">
      mailbox  - the mailbox name (username)
     </span>
    </li>
    <li class="listitem">
     <span class="simpara">
      host - the host name
     </span>
    </li>
    <li class="listitem">
     <span class="simpara">
      personal - the personal name
     </span>
    </li>
    <li class="listitem">
     <span class="simpara">
      adl - at domain source route
     </span>
    </li>
   </ul>
  </p>
 </div>

 <div class="refsect1 examples" id="refsect1-function.imap-rfc822-parse-adrlist-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-3002">
    <p><strong>示例 #1 <span class="function"><strong>imap_rfc822_parse_adrlist()</strong></span> example</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br />$address_string&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">"Joe&nbsp;Doe&nbsp;&lt;doe@example.com&gt;,&nbsp;postmaster@example.com,&nbsp;root"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$address_array&nbsp;&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">imap_rfc822_parse_adrlist</span><span style="color: #007700">(</span><span style="color: #0000BB">$address_string</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"example.com"</span><span style="color: #007700">);<br />if&nbsp;(!</span><span style="color: #0000BB">is_array</span><span style="color: #007700">(</span><span style="color: #0000BB">$address_array</span><span style="color: #007700">)&nbsp;||&nbsp;</span><span style="color: #0000BB">count</span><span style="color: #007700">(</span><span style="color: #0000BB">$address_array</span><span style="color: #007700">)&nbsp;&lt;&nbsp;</span><span style="color: #0000BB">1</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;die(</span><span style="color: #DD0000">"something&nbsp;is&nbsp;wrong\n"</span><span style="color: #007700">);<br />}<br /><br />foreach&nbsp;(</span><span style="color: #0000BB">$address_array&nbsp;</span><span style="color: #007700">as&nbsp;</span><span style="color: #0000BB">$id&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">$val</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"#&nbsp;</span><span style="color: #0000BB">$id</span><span style="color: #DD0000">\n"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"&nbsp;&nbsp;mailbox&nbsp;:&nbsp;"&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #0000BB">$val</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">mailbox&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"&nbsp;&nbsp;host&nbsp;&nbsp;&nbsp;&nbsp;:&nbsp;"&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #0000BB">$val</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">host&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"&nbsp;&nbsp;personal:&nbsp;"&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #0000BB">$val</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">personal&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"&nbsp;&nbsp;adl&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:&nbsp;"&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #0000BB">$val</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">adl&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br />}<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

    <div class="example-contents"><p>以上例程会输出：</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
# 0
  mailbox : doe
  host    : example.com
  personal: Joe Doe
  adl     : 
# 1
  mailbox : postmaster
  host    : example.com
  personal: 
  adl     : 
# 2
  mailbox : root
  host    : example.com
  personal: 
  adl     :

</pre></div>
    </div>
   </div>
  </p>
 </div>

 <div class="refsect1 seealso" id="refsect1-function.imap-rfc822-parse-adrlist-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="function.imap-rfc822-parse-headers.html" class="function" rel="rdfs-seeAlso">imap_rfc822_parse_headers()</a> - Parse mail headers from a string</span></li>
   </ul>
  </p>
 </div>

</div></div></div></body></html>